<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="./layui/css/layui.css">
    <link rel="stylesheet" href="./css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body style="background-color: white">
<div class="layui-form layuimini-form">

    <div class="layui-form-item layui-anim-down">
        <label class="layui-form-label">订单ID</label>
        <div class="layui-input-block">
            <span style="line-height: 38px;color: teal">${order.id}</span>
            <input type="hidden" name="id" value="${order.id}">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">客户ID</label>
        <div class="layui-input-block">
            <span style="line-height: 38px;color: teal">${order.customerId}</span>
            <input type="hidden" name="customerId" lay-verify="required" value="${order.customerId}" lay-reqtext="id不能为空" placeholder="请输入id" value="" class="layui-input" autocomplete="off">
<%--            <tip>填写自己客户的ID号</tip>--%>
<%--            <div class="layui-input-inline">--%>
<%--            <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" id="searchCustomer">--%>
<%--                <i class="layui-icon layui-icon-user" style="color: #1E9FFF"></i>--%>
<%--            </button>--%>
<%--            </div>--%>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label required">付费日期</label>
        <div class="layui-input-block">
            <fmt:formatDate value="${order.payDate}" pattern="yyyy-MM-dd"/>
            <input type="hidden" class="layui-input" id="test1" placeholder="yyyy-MM-dd HH:mm:ss" value="<fmt:formatDate value="${order.payDate}" pattern="yyyy-MM-dd"/>" name="payDate" lay-verify="required">
        </div>
    </div>
<%--    <div class="layui-form-item">--%>
<%--        <label class="layui-form-label required">到期日期</label>--%>
<%--        <div class="layui-input-block">--%>
<%--            <input type="hidden" class="layui-input" id="test2" placeholder="yyyy-MM-dd HH:mm:ss" value="<fmt:formatDate value="${order.maturityDate}" pattern="yyyy-MM-dd"/>" name="maturityDate" lay-verify="required">--%>
<%--        </div>--%>
<%--    </div>--%>
    <div class="layui-form-item">
        <label class="layui-form-label required">付费金额</label>
        <div class="layui-input-block">
            <span style="line-height: 38px;color: teal">${order.cost}</span>
            <input type="hidden" name="cost" placeholder="请输入金额" value="${order.cost}" class="layui-input" autocomplete="off" lay-verify="required">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">支付方式类型</label>
        <div class="layui-input-block">
<%--            <input type="text" name="payType" value="${order.payType}" placeholder="请输入类型数字编号即可" value="${order.payType}" class="layui-input" autocomplete="off">--%>
                <select name="payType" lay-filter="select" id="payType" lay-verify="required">
                    <option value=""></option>
                    <option value="1">支付宝</option>
                    <option value="2">现金支付</option>
                    <option value="3">微信支付</option>
                </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">办理类型</label>
        <span style="line-height: 38px;color: teal">${order.processingType}</span>
       <%-- <div class="layui-input-block">
            <select name="processingType" id="processingType" lay-verify="required">
                <option value=""></option>
                <option value="包年">包年</option>
                <option value="包月">包月</option>
            </select>
        </div>--%>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>

</div>

<script src="./layui/layui.js"></script>

<script>
    layui.use(['form','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate,
            $ = layui.$;

        //渲染默认
        $("#payType").val(${order.payType});
        $("#processingType").val('${order.processingType}');
        form.render();




        //
        // $("#searchCustomer").click(function (){
        //     window.parent.parent.layer.open({
        //         type: 2,
        //         title: '很多时候，我们想左右协同，比如像这个页面。',
        //         shadeClose: true,
        //         shade: false,
        //         maxmin: true, //开启最大化最小化按钮
        //         area: ['893px', '600px'],
        //         content: './customerTable'
        //     });
        // })

        //日期时间选择器
        laydate.render({
            elem: '#test1',
            // type: 'datetime'
        });
        laydate.render({
            elem: '#test2',
            // type: 'datetime'
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {

            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {
                // 关闭弹出层
                /* layer.close(index);
                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex); */

                $.ajax({
                    url:'./updateOrder',
                    type:'post',
                    data:data.field,

                   /*   beforeSend:function () {
                         this.layerIndex = layer.load(0, { shade: [0.5, '#393D49'] });
                     },*/
                    success:function(data){
                        if(data.status == 'error'){
                            layer.msg('失败',{icon: 5});//失败的表情
                            o.removeClass('layui-btn-disabled');
                            return;
                        }else{
                            layer.msg('成功', {
                                icon: 6,//成功的表情
                                time: 2000, //1秒关闭（如果不配置，默认是3秒）
                                // scrollbar: false
                            }, function(){
                                layer.close(index);
                                var iframeIndex = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(iframeIndex);
                                window.parent.location.reload();
                            });
                        }
                    },
                    error:function(e){
                        layer.msg("失败",
                            {
                                //失败的表情
                                icon: 5
                            },
                            function(){
                                location.reload();
                            });
                        console.log(e);
                    },

                });

            });

            return false;
        });

    });
</script>
</body>
</html>